package com.szrt.ch05;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/CookieServlet.do")
public class CookieServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) 
			
			throws ServletException, IOException {
		
		Cookie cookie=  new Cookie("school", "szrt");
		cookie.setMaxAge(10);
		
		cookie.setValue("beijingdaxue");
		resp.addCookie(cookie);
		
		
		//请求转发
		req.getRequestDispatcher("/cookie/aa.jsp").forward(req, resp);
		
		
		
		
		
		System.out.println("CookieServlet ....");
	}

}
